import { ref } from 'vue'

export default class MyLoader {
  resultTips = ref<string>('')
  loading = ref<boolean>()
  timer: number | undefined

  constructor() {
    this.loading.value = false
    this.resultTips.value = ''
    this.timer = undefined
  }

  setTips(msg: string, time: number = 3600): void {
    clearTimeout(this.timer)
    this.resultTips.value = msg

    this.timer = setTimeout(
      () => (this.resultTips.value = ''),
      time
    ) as unknown as number
  }
}
